//
//  DeliverSuccessViewController.m
//  u76ho
//
//  Created by m-air-01 on 16/1/19.
//  Copyright © 2016年 LV. All rights reserved.
//

#import "DeliverSuccessViewController.h"
#import "PositionDeliverDetailModel.h"
@interface DeliverSuccessViewController ()

@end

@implementation DeliverSuccessViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self main];
    self.navigationItem.title = @"投递反馈";
    [self addBackItem];
    //[self addNavgationBar];
    // Do any additional setup after loading the view.
}
-(void)main
{
    self.view.backgroundColor = UIColorFromRGB(0xf1f3f2);
    
    [self requestData];
}
-(void)requestData
{
    __weak typeof(self)weakSelf = self;
    [U76HONet feedBackDetailWithActon:@"" idm:_idm andDateBlcok:^(PositionDeliverDetailModel *model) {
        NSLog(@"投递反馈获取数据成功列");
        if ([model.viewstage isEqualToString:@"3"] || [model.viewstage isEqualToString:@"3"]) {
            [weakSelf successWithmodel:model];

        }
        else
        {
            [weakSelf failedWithmodel:model];

        }
    }];
}
-(void)failedWithmodel:(PositionDeliverDetailModel *)model
{
    //topView
    UIView * topView = [[UIView alloc]initWithFrame:CGRectMake(0, 56, SCREEN_WIDTH, SIZETO6H(7))];
    topView.backgroundColor = [UIColor greenColor];
    [self.view addSubview:topView];
    
    //contentView
    UIView * contentView = [[UIView alloc]initWithFrame:CGRectMake(0, topView.bottom, SCREEN_WIDTH, SIZETO6H(196))];
    contentView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:contentView];
    
    UILabel * topLab = [[UILabel alloc]initWithFrame:CGRectMake(SIZETO6W(15), SIZETO6H(32), 120, 20)];
    topLab.text = @"温馨提醒";
    topLab.textColor = UIColorFromRGB(0x333944);
    topLab.font = [UIFont systemFontOfSize:18];
    [contentView addSubview:topLab];
    
    UILabel * timeLab = [[UILabel alloc]initWithFrame:CGRectMake(topLab.left, topLab.bottom+SIZETO6H(6), 120, 20)];
    timeLab.textColor = UIColorFromRGB(0x94999F);
    
    //时间
    NSDateFormatter * formatter = [[NSDateFormatter alloc]init];
    formatter.dateFormat = @"yyyy-MM-dd";
    NSString * dataCh = model.endtime;
    NSString * dataStr = [dataCh substringToIndex:dataCh.length];
    NSDate * data = [[NSDate dateWithTimeIntervalSince1970:[dataStr integerValue]] dateByAddingTimeInterval:8*3600];
    NSString * lastStr = [NSString stringWithFormat:@"%@",data];
    NSArray * lastArr = [lastStr componentsSeparatedByString:@" "];

    
    timeLab.text = lastArr[0];
    timeLab.font = [UIFont systemFontOfSize:14];
    [contentView addSubview:timeLab];
    
    UITextView * contentLab = [[UITextView alloc]initWithFrame:CGRectMake(SIZETO6W(15), timeLab.bottom+SIZETO6H(24), SCREEN_WIDTH-SIZETO6W(15)*2, contentView.height-timeLab.bottom-SIZETO6H(24))];
    contentLab.text = model.content;
    contentLab.font = [UIFont systemFontOfSize:15];
    contentLab.editable = NO;
    contentLab.textColor = UIColorFromRGB(0x616978);
    [contentView addSubview:contentLab];

}
-(void)successWithmodel:(PositionDeliverDetailModel *)model
{
    //topView
    UIView * topView = [[UIView alloc]initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SIZETO6H(7))];
    topView.backgroundColor = [UIColor greenColor];
    [self.view addSubview:topView];
    
    //contentView
    UIView * contentView = [[UIView alloc]initWithFrame:CGRectMake(0, topView.bottom, SCREEN_WIDTH, SIZETO6H(333))];
    contentView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:contentView];
    
    UILabel * topLab = [[UILabel alloc]initWithFrame:CGRectMake(SIZETO6W(15), SIZETO6H(10), 120, 20)];
    topLab.text = @"面试通知提醒";
    topLab.textColor = UIColorFromRGB(0x333944);
    topLab.font = [UIFont systemFontOfSize:18];
    [contentView addSubview:topLab];
    
    UILabel * timeLab = [[UILabel alloc]initWithFrame:CGRectMake(topLab.left, topLab.bottom+SIZETO6H(6), 120, 20)];
    timeLab.textColor = UIColorFromRGB(0x94999F);
    //时间
    NSDateFormatter * formatter = [[NSDateFormatter alloc]init];
    formatter.dateFormat = @"yyyy-MM-dd";
    NSString * dataCh = model.endtime;
    NSString * dataStr = [dataCh substringToIndex:dataCh.length];
    NSDate * data = [[NSDate dateWithTimeIntervalSince1970:[dataStr integerValue]] dateByAddingTimeInterval:8*3600];
    NSString * lastStr = [NSString stringWithFormat:@"%@",data];
    NSArray * lastArr = [lastStr componentsSeparatedByString:@" "];
    
    
    timeLab.text = lastArr[0];

    timeLab.font = [UIFont systemFontOfSize:14];
    [contentView addSubview:timeLab];
    
    UILabel * nameLab = [[UILabel alloc]initWithFrame:CGRectMake(timeLab.left, timeLab.bottom+SIZETO6H(20), 120, 20)];
    nameLab.textColor = UIColorFromRGB(0x616978);
    nameLab.text = @"你好";
    nameLab.font = [UIFont systemFontOfSize:15];
    [contentView addSubview:nameLab];
    
    UILabel * yaoqingLab = [[UILabel alloc]initWithFrame:CGRectMake(nameLab.left, nameLab.bottom+SIZETO6H(5), SCREEN_WIDTH-SIZETO6W(15)*2, 20)];
    yaoqingLab.text = model.content;
    yaoqingLab.textColor = UIColorFromRGB(0x616978);
    yaoqingLab.font = [UIFont systemFontOfSize:15];
    [contentView addSubview:yaoqingLab];
    
    UILabel * dutyLab = [[UILabel alloc]initWithFrame:CGRectMake(yaoqingLab.left, SIZETO6H(20)+yaoqingLab.bottom, 120, 20)];
    dutyLab.textColor = UIColorFromRGB(0x616978);
    dutyLab.text = @"面试职位:";
    dutyLab.font = [UIFont systemFontOfSize:16];
    [contentView addSubview:dutyLab];
    
    UILabel * dutyIsLab = [[UILabel alloc]initWithFrame:CGRectMake(dutyLab.right, dutyLab.top, SCREEN_WIDTH-dutyLab.right-20, 20)];
    dutyIsLab.textColor = UIColorFromRGB(0x616978);
    dutyIsLab.text = model.dutyname;
    dutyIsLab.font = [UIFont systemFontOfSize:16];
    [contentView addSubview:dutyIsLab];
    
    UILabel * suoshuLab = [[UILabel alloc]initWithFrame:CGRectMake(dutyLab.left, dutyLab.bottom+SIZETO6H(10), dutyLab.width, 20)];
    suoshuLab.text = @"所属公司:";
    suoshuLab.textColor = UIColorFromRGB(0x616978);
    suoshuLab.font = [UIFont systemFontOfSize:16];
    [contentView addSubview:suoshuLab];
    
    UILabel * suoshuIsLab = [[UILabel alloc]initWithFrame:CGRectMake(suoshuLab.right, suoshuLab.top, SCREEN_WIDTH-suoshuLab.right-20, 20)];
    suoshuIsLab.text = model.companyname;
    suoshuIsLab.textColor = UIColorFromRGB(0x616978);
    suoshuIsLab.font = [UIFont systemFontOfSize:16];
    [contentView addSubview:suoshuIsLab];
    
    UILabel *  mianshiTimeLab = [[UILabel alloc]initWithFrame:CGRectMake(suoshuLab.left, suoshuLab.bottom+SIZETO6H(5), suoshuLab.width, 20)];
    mianshiTimeLab.textColor = UIColorFromRGB(0x616978);
    mianshiTimeLab.text = @"面试时间:";
    mianshiTimeLab.font = [UIFont systemFontOfSize:16];
    [contentView addSubview:mianshiTimeLab];
    
    //时间
    NSString * dataCh2 = model.viewtime;
    NSString * dataStr2 = [dataCh2 substringToIndex:dataCh2.length-3];
    NSDate * data2 = [[NSDate dateWithTimeIntervalSince1970:[dataStr2 integerValue]] dateByAddingTimeInterval:8*3600];
    NSString * lastStr2 = [NSString stringWithFormat:@"%@",data2];
    NSArray * lastArr2 = [lastStr2 componentsSeparatedByString:@" "];

    
    UILabel * mianshiTimeIsLab = [[UILabel alloc]initWithFrame:CGRectMake(mianshiTimeLab.right, mianshiTimeLab.top, SCREEN_WIDTH-mianshiTimeLab.right-20, 20)];
    mianshiTimeIsLab.textColor = UIColorFromRGB(0x616978);
    mianshiTimeIsLab.text = lastArr2[0];
    mianshiTimeIsLab.font = [UIFont systemFontOfSize:16];
    [contentView addSubview:mianshiTimeIsLab];
    
    UILabel * mianshiAddLab = [[UILabel alloc]initWithFrame:CGRectMake(mianshiTimeLab.left, mianshiTimeLab.bottom+SIZETO6H(5), mianshiTimeLab.width, 20)];
    mianshiAddLab.text = @"面试地点:";
    mianshiAddLab.textColor = UIColorFromRGB(0x616978);
    mianshiAddLab.font = [UIFont systemFontOfSize:16];
    [contentView addSubview:mianshiAddLab];
    
    UILabel * mianshiAddIsLab = [[UILabel alloc]initWithFrame:CGRectMake(mianshiAddLab.right, mianshiAddLab.top, SCREEN_WIDTH-mianshiAddLab.right-20, 20)];
    mianshiAddIsLab.text = model.address;
    mianshiAddIsLab.textColor = UIColorFromRGB(0x616978);
    mianshiAddIsLab.font = [UIFont systemFontOfSize:16];
    [contentView addSubview:mianshiAddIsLab];
    
    UILabel * contantPeopleLab = [[UILabel alloc]initWithFrame:CGRectMake(mianshiAddLab.left, mianshiAddLab.bottom+SIZETO6H(5), mianshiAddLab.width, 20)];
    contantPeopleLab.textColor = UIColorFromRGB(0x616978);
    contantPeopleLab.text = @"联系人:";
    contantPeopleLab.font = [UIFont systemFontOfSize:16];
    [contentView addSubview:contantPeopleLab];
    
    UILabel * contantPeopleIsLab = [[UILabel alloc]initWithFrame:CGRectMake(contantPeopleLab.right, contantPeopleLab.top, SCREEN_WIDTH-contantPeopleLab.right-20, 20)];
    contantPeopleIsLab.textColor = UIColorFromRGB(0x616973);
    contantPeopleIsLab.text = model.hr;
    contantPeopleIsLab.font = [UIFont systemFontOfSize:16];
    [contentView addSubview:contantPeopleIsLab];
    
    UILabel * iphoneLab = [[UILabel alloc]initWithFrame:CGRectMake(contantPeopleLab.left, contantPeopleLab.bottom+SIZETO6H(5), contantPeopleLab.width, 20)];
    iphoneLab.text = @"联系电话:";
    iphoneLab.textColor = UIColorFromRGB(0x616978);
    iphoneLab.font = [UIFont systemFontOfSize:16];
    [contentView addSubview:iphoneLab];
    
    UILabel * iphoneIsLab = [[UILabel alloc]initWithFrame:CGRectMake(iphoneLab.right, iphoneLab.top, SCREEN_WIDTH-iphoneLab.right-20, 20)];
    iphoneIsLab.text = model.tel;
    iphoneIsLab.textColor = UIColorFromRGB(0x616973);
    iphoneIsLab.font = [UIFont systemFontOfSize:16];
    [contentView addSubview:iphoneIsLab];
    
    contentView.height = iphoneIsLab.bottom + 20;
}
#pragma  mark - 返回按钮图标
-(void)addBackItem{
    UIButton * backItem = [UIButton buttonWithType:UIButtonTypeCustom];
    backItem.frame = CGRectMake(0, 0, 9, 17);
    [backItem setImage:[UIImage imageNamed:@"返回图标"] forState:UIControlStateNormal];
    [backItem addTarget:self action:@selector(backItem:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backItem];
}
-(void)backItem:(id)sender
{
    if (_isAPNS) {
        AppDelegate * app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
        self.view.window.rootViewController = app.viewController;
    }else{
        [self.navigationController popViewControllerAnimated:YES];
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
